package com.bestdreamer.optional;

import java.util.Optional;
import java.util.function.Predicate;


public class OptionalFilter {

    public static void main(String[] args) {
        String password = "1234567";
        Optional<String> opt = Optional.ofNullable(password);

        Predicate<String> len6 = pwd -> pwd.length() > 6;
        Predicate<String> len10 = pwd -> pwd.length() < 10;
        Predicate<String> eq = pwd -> !pwd.equals("password");
        boolean result = opt.map(String::toLowerCase).filter(len6.and(len10).and(eq)).isPresent();
        System.out.println(result);
    }
}
